<?php include_once 'common/header.php';  ?>
<?php
	$borrow_check = array(0=>'未检查',1=>'数据已检查');
?>
<!-- admin_main -->
<div class="admin_main">
	<!-- Admin_top end -->
	<?php include_once 'common/borrow_left.php';  ?>
	<!-- Admin_Left End -->
	<div class="admin_right">
	<div class="admin_right_title"><strong>贷款管理</strong> >> 贷款详情</div>
		<div class="admin_borrow">
			<div class="admin_borrow_title">
				<h2><img width="60" height="60" src="/<?php echo BORROW_IMG;?>/<?php echo $borrow['thumbnail'] ? $borrow['thumbnail']:'static/data/avatar/noavatar_small.jpg';?>" width="60" height="60"  /><?php echo $borrow['title'];?></h2>

				<ul>
					<li class="admin_borrow_bg">借款编号</li>
					<li><?php echo $borrow['project_number'];?></li>
					<li class="admin_borrow_bg">借款金额</li>
					<li><font><?php echo number_format($borrow['account'],2);?></font></li>
					<li class="admin_borrow_bg">借款期限</li>
					<li><?php if($borrow['is_day'] == 1){echo $borrow['time_limit_day'].'天'; }else{echo $borrow['time_limit'].'个月';}?> <?php if($borrow['ftype'] == 4){?>流转标期数：<?php echo $borrow['lz_times'];?><?php }?></li>
					<li class="admin_borrow_bg">年化利率</li>
					<li><font><?php echo $borrow['apr'];?>%</font></li>
					<li class="admin_borrow_bg">标种：</li>
					<li class="b r"><font><?php echo $borrow_type[$borrow['ftype']];?></font></li>

					 <li class="admin_borrow_bg">状态：</li>
					<li class=""><?php echo $borrow_status[$borrow['fstatus']];?></li>

					<li class="admin_borrow_bg">已投资金额：	</li>
					<li><?php echo number_format($borrow['account_yes'],2);?>元</li>
					<li class="admin_borrow_bg">剩余金额：</li>
					<li  class=""><?php echo number_format($borrow['account']-$borrow['account_yes'],2);?>元</li>

					<li class="admin_borrow_bg">还款方式：</li>
					<li><?php echo $borrow_style[$borrow['style']];?></li>
					<li class="admin_borrow_bg">是否奖励</li>
					<li class="b r"><?php if($borrow['award'] == 2){?>奖励比例：<font><?php echo $borrow['funds'];?>%</font><?php }else{?>不奖励<?php }?> </li>


					<li class="admin_borrow_bg">有效时间</li>
					<li ><?php echo $borrow['valid_time'];?>天</li>

					<li class="admin_borrow_bg">最小投标金额</li>
					<li class="b"><?php echo number_format($borrow['lowest_account'],2);?>元</li>


					<li class="admin_borrow_bg">最大投标金额</li>
					<li><?php echo $borrow['most_account']>0 ? number_format($borrow['most_account'],2)."元":"无限制";?></li>
					<li class="b admin_borrow_bg">投资开放时间：</li>
					<li class="b"><?php if($borrow['auto_verify_time'] >0){ echo date('Y-m-d H:i', $borrow['auto_verify_time']);}?>&nbsp;</li>
					<li class="b admin_borrow_bg">发标时间：</li>
					<li class="b r"><?php  if($borrow['verify_time']>0){ echo date('Y-m-d H:i', $borrow['verify_time']);} ?>&nbsp;</li>
					<li class="b admin_borrow_bg">是否推荐：</li>
					<li class="b"><?php  if($borrow['recommend_id']>0){ echo '是';}else{ echo '否';} ?>&nbsp;</li>
					<li class="b admin_borrow_bg">机构：</li>
					<li class="b r" title="<?php echo $guarantee_name_list[$borrow['guarantee_id']];?>"><?php echo cut_str($guarantee_name_list[$borrow['guarantee_id']],8);?>&nbsp;</li>
                                        <?php if ($borrow['ftype'] == 2){?>
                                        <li class="b admin_borrow_bg">抵(质)押物：</li>
					<li class="b r" title="<?php echo $borrow['cltroGoods'];?>"><?php echo $borrow['cltroGoods'];?>&nbsp;</li>
                                        <?php }?>
					<!--
                                        <li class="b admin_borrow_bg">平台费率：</li>
					<li class="b r"><?php echo number_format($borrow['borrow_fee'],2);?>&nbsp;</li>
                                        -->
				</ul>
			</div>

			<div class="admin_borrow_title" style="margin: 10px 0;">
				<h2>投标记录</h2>
				<div class="borrow_content_wrap" style="display: block;">
				<?php if($borrow_tender_list){?>
				<table width="100%" border="0" cellpadding="0" cellspacing="0" class="funds graytable">
                    <tbody>
                         <tr class="title">
                                        <th width="15%">投资人/关系</th>
                                        <th width="15%">当前年利率</th>
                                        <th width="15%">投标金额</th>
                                        <th width="15%">有效金额</th>
                                        <th width="15%">投标时间</th>
										<th width="15%">状态</th>
										<th width="15%">操作</th>
                        </tr>
                         <?php foreach($borrow_tender_list as $borrow_tender){ ?>
                         	 <tr>
	                           <td><div class="font_lan"><a href="javascript:showUser(<?php echo $borrow_tender['user_id'];?>);"><?php echo $borrow_tender['username'];?></a></div></td>
	                           <td><?php echo $borrow['apr'];?>%</td>
	                           <td><div class="font_Orange"><?php echo number_format($borrow_tender['money'],2);?>元</div></td>
	                           <td><div class="font_Orange"><?php echo number_format($borrow_tender['account'],2);?>元</div></td>
	                           <td><?php echo date('m-d H:i',$borrow_tender['add_time']);?></td>
							  <td><div class="font_lan">
							  	<?php if(($borrow_tender['money'] == $borrow_tender['account']) && $borrow_tender['fstatus'] != 3){?>
							  		<font>全部通过</font>
							  	<?php }else if($borrow_tender['fstatus'] == 3){?>
							  			已撤回
							  	<?php }else{?>
							  		部分通过
							  	<?php }?>
							  	</div>
							  </td>
							  <td>
							  		<?php if($borrow['fstatus'] != 3  && $borrow_tender['fstatus'] != 3 && $borrow['ftype']!=4){?>
							  			<!--<a href="javascript:if(confirm('你确定撤回？')){withdraw_the_tender(<?php echo $borrow_tender['id'];?>);}">撤标</a>
							  		--><?php }else{?> ---<?php }?>
							  </td>
							</tr>
                         <?php }?>
                    </tbody>
                </table>
               <?php }else{?>
               		<p>暂无数据</p>
                <?php }?>
			</div>
			</div>

			<div class="admin_borrow_title" style="margin: 10px 0;">
				<h2>资料证明信息</h2>
				<div class="borrow_content_wrap" style="display: block;">
				<?php if($list){?>
					<table border="0" cellspacing="1" cellpadding="0" bgcolor="#dcdcdc" width="100%">
						<tr style="color: #636363;">
							<td height="35" align="center" valign="middle" bgcolor="#F1F1F1"><strong>ID</strong></td>
							<td height="35" align="center" valign="middle" bgcolor="#F1F1F1"><strong>用户名</strong></td>
							<td height="35" align="center" valign="middle" bgcolor="#F1F1F1"><strong>真实姓名</strong></td>
							<td height="35" align="center" valign="middle" bgcolor="#F1F1F1"><strong>资料类型</strong></td>
							<td height="35" align="center" valign="middle" bgcolor="#F1F1F1"><strong>图片</strong></td>
							<td height="35" align="center" valign="middle" bgcolor="#F1F1F1"><strong>状态</strong></td>
							<td height="35" align="center" valign="middle" bgcolor="#F1F1F1"><strong>获得积分</strong></td>
							<td height="35" align="center" valign="middle" bgcolor="#F1F1F1"><strong>简介</strong></td>
							<td height="35" align="center" valign="middle" bgcolor="#F1F1F1"><strong>上传时间</strong></td>
						</tr>
						<?php foreach($list as $val){?>
						<tr>
							<td height="35" align="center" valign="middle" bgcolor="#FFFFFF"><?php echo $val['id'];?></td>
							<td height="35" align="center" valign="middle" bgcolor="#FFFFFF"><?php echo $userinfo['username'];?></td>
							<td height="35" align="center" valign="middle" bgcolor="#FFFFFF"><?php echo $userinfo['realname'];?></td>
							<td height="35" align="center" valign="middle" bgcolor="#FFFFFF"><?php echo $type_list[$val['type_id']];?></td>
							<td height="35" align="center" valign="middle" bgcolor="#FFFFFF"><a
								href="/<?php echo $val['litpic']?>" target="_blank"><img
								style="width: 60px; height: 30px;" src="/<?php echo $val['litpic']?>"
								alt="<?php echo $val['name']?>" /></a></td>
							<td height="35" align="center" valign="middle" bgcolor="#FFFFFF"><?php echo $status_list[$val['fstatus']];?></td>
							<td height="35" align="center" valign="middle" bgcolor="#FFFFFF"><?php echo $val['jifen'];?></td>
							<td height="35" align="center" valign="middle" bgcolor="#FFFFFF"><?php echo $val['content'];?></td>
							<td height="35" align="center" valign="middle" bgcolor="#FFFFFF"><?php echo date('Y-m-d H:i:s',$val['add_time']);?></td>
						</tr>
						<?php }?>
					</table>
               <?php }else{?>
               		<p>暂无数据</p>
                <?php }?>
			    </div>
			</div>

			<div class="admin_borrow_title" style="margin: 10px 0;">
				<h2>信息概述</h2>
				<div class="borrow_content_wrap">
					<h3>项目概述</h3>
					<p><?php echo $borrow['content'];?></p>
					<h3>融资用途</h3>
					<p><?php echo $borrow['fuse'];?></p>
					<h3>还款来源：</h3>
					<p><?php echo $borrow['repay_from'];?></p>
					<h3>风控措施：</h3>
					<p><?php echo $borrow['risk_manage'];?></p>
					<h3>评审决议</h3>
					<p><?php echo $borrow['verify_remark'];?></p>
				</div>
			</div>

			<!-- 
			<div class="admin_borrow_title" style="margin: 10px 0;">
				<h2>项目评论</h2>
				<div class="borrow_content_wrap" id="comments_lists">
                    <?php echo $response_html;?>
				</div>
	        </div>
			 -->

		</div>

<!-- Admin_Right End -->
    </div>
</div>
<!-- admin_main end -->

<div id="dialogshowuser" title="用户信息" style="display:none">
	<div id="view_response"></div>
</div>

<script type="text/javascript">
function withdraw_the_tender(borrow_id){
	$.ajax({
		type: "get",
		url: "/ychadmin/borrow/borrow_single/"+borrow_id,
		success: function(msg){
			$("#dialog" ).dialog();
			if(msg == 1){
				$("#msg").html("撤标成功！");
				$("#chebiao_"+borrow_id).hide();
			}else{
				$("#msg").html("撤标失败，请联系管理员！");
			}
			setTimeout(function(){
				$("#dialog" ).dialog("close");
				window.location.reload();
			},3000);
		},
		dataType: "text"
	});
}


function load_comment(bid,pg){
	$.ajax({
		url: '/ychadmin/borrow/borrow_view?r='+Math.round(Math.random()*1000),
		data: {from: 'ajax', pg: pg,borrow_id:bid},
		type:'GET',
		success: function(txt){
			$("#comments_lists").html(txt);
		}
	});
}

function showUser(user_id){
	$.ajax({
		type: "POST",
		url: "/ychadmin/user/showDetailInfo",
		data: "user_id="+user_id,
		success: function(ret){
				$('#dialogshowuser').dialog({
					width:650,
					height:600,
					title:'用户信息',
					buttons:{"确定":function(){$(this).dialog("close");}},
				});
				$("#view_response").html(ret);

		},
		dataType: "text"
	});

}

</script>



<div id="dialog" title="系统提示" style="display:none"><p id="msg" style="text-align:center"></p></div>
</body>
</html>
